import React, { useLayoutEffect } from 'react'
import type { VariableSizeList as List } from 'react-window'
import { CONSTANT } from '../../../utils/utils'
import { PendingItem, PendingMt } from '../../../translator'

export const useHeight = (list: PendingItem<PendingMt>[], searchType: 2 | 1 | null) => {
	let ref = React.createRef<List>()
	let height: number[] = []
	if (searchType === CONSTANT.searchType.simple) {
		height = list.map((x) => (x.status.isParent ? 22 : 45))
	} else {
		height = list.map((x) => 22)
	}
	useLayoutEffect(() => {
		if (ref.current) {
			ref.current.resetAfterIndex(0, false)
		}
	})
	return { height, ref }
}
